<script language="Javascript">
	function send(){
		document.getElementById('submit').disabled = (document.getElementById('Num').value==0)?true:false;
	}
</script>
<?php
class Form_AjouterPhoto extends Zend_Form{
	
	
	public function init(){
		$this->setMethod('post');
		$this->setName('ajouterphoto');
		$this->setAttrib('enctype','multipart/form-data');

		$listeVips = PhotosController::listevipsAction();

		$addNom = new Zend_Form_Element_Select('Num');
		$addNom ->setLabel('Nom du vip : ')
						->setAttrib('onclick', "send();")
						->addMultiOption(0, "Selectionnez un nom ");
		
		foreach($listeVips as $vip){
			$addNom ->addMultiOption($vip->VIP_NUMERO, $vip->VIP_NOM." ".$vip->VIP_PRENOM);
		}
		
		$addPhoto =new Zend_Form_Element_File('photo');
		$addPhoto->setLabel('Selectionner l\'image :')
        		->setDestination('./images/photos/')
				->addValidator('Count', false, 1)
				->addValidator('Size', false, 100000000000000)
				->addValidator('Extension', false, 'jpg,png,gif');
		
		$addTitre = new Zend_Form_Element_Text('titre');
		$addTitre	->setLabel("Titre* : ")
						->addFilter('StripTags')
						->addValidator('alnum', false, array('allowWhiteSpace'=>true))
						->addValidator('StringLength', false, array(3,50))
						->addFilter('StringTrim')
						->setRequired(TRUE);
						
						
		$addCommentaire = new Zend_Form_Element_Textarea('commentaire');
		$addCommentaire ->setLabel('Commentaire : ')
						->addFilter('StripTags')
						->addValidator('alnum', false, array('allowWhiteSpace'=>true))
						->addFilter('StringTrim')
						->setAttrib('cols', '40')
						->setAttrib('rows', '4');
						
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setLabel('Envoyer');
		
		$this->addElements(array($addNom,$addTitre,$addPhoto,$addCommentaire, $submit));
		
		?>
		<script language="Javascript">
			send();
		</script>
		<?php 
		
		//On modifie les styles par default
		
		$this->setElementDecorators(array('ViewHelper','Description','Errors',
                   array(array('data'=>'HtmlTag'), array('tag' => 'td')),
                   array('Label', array('tag' => 'td')),
                   array(array('row'=>'HtmlTag'),array('tag'=>'tr'))));
                   
        $addPhoto->setDecorators(
			    array(
			        'File',
			        'Errors',
			        array(array('data' => 'HtmlTag'), array('tag' => 'td')),
			        array('Label', array('tag' => 'th')),
			        array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
			    )
		);
        
		$submit->setDecorators(array(
				'ViewHelper','Description','Errors', array(array('data'=>'HtmlTag'),
				array('tag' => 'td','colspan'=>'2','align'=>'left')),
				array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
       ));
       
		
		$this->setDecorators(array('FormElements', array(array('data'=>'HtmlTag'),array('tag'=>'table')),'Form'));
	}
	
}